package com.ljy.my_study.leetcode.寻找峰值;

/**
 * @author lijunying
 * @date 2021/9/15 9:27
 */
public class TestMain2 {

//    二分查找
    public int findPeakElement(int[] nums) {
        int len=nums.length;
        if(len==1){
            return 0;
        }
        int left=0;
        int right=len-1;
        while(left<right){
            int mid=(left+right)/2;
            if(nums[mid]<nums[mid+1]){
                left=mid+1;
            }else{
                right=mid;
            }
        }
        return right;
    }
}
